package homework;

public class CamelToSnake {

    public String camelToSnake(String string){
        char[] chars1 = string.toCharArray();
        string = string.toLowerCase();
        StringBuffer stringBuffer = new StringBuffer(string);
        char[] chars2 = string.toCharArray();
        int index = 0;
        for (int i = 0; i < chars1.length; i++){

            if (!(chars1[i] == chars2[i]) && i != 0){
                stringBuffer.insert(i + index, "_");
                index++;
            }


        }
        ;
        return stringBuffer.toString();
    }



}
